package janelas;

import java.util.ResourceBundle;
import javax.swing.JOptionPane;
import projetofinaltecnicas.Main;

/**
 *
 * @author itallorossi
 */
public class MenuUsuario extends javax.swing.JInternalFrame {
    
    ReservarSala salaRes;
    VerificarReservas reservas;
    SalasDisponiveis salaDispo;

    String idioma;
    String usuario;

    /** Creates new form MenuUsuario */
    public MenuUsuario(String idioma, String usuario) {
        initComponents();

        alterarIdioma(idioma);

        this.salaRes = new ReservarSala(idioma,usuario);
        this.reservas = new VerificarReservas(idioma,usuario);
        this.salaDispo = new SalasDisponiveis(idioma,usuario);

        this.idioma = idioma;
        this.usuario = usuario;

        jiduser.setText(usuario);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        desktop = new javax.swing.JDesktopPane();
        titulo = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        juser = new javax.swing.JLabel();
        jiduser = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuUsuario = new javax.swing.JMenu();
        jMenuVerificarSolicitacao = new javax.swing.JMenuItem();
        jMenuReserva = new javax.swing.JMenu();
        jMenuReservaSala = new javax.swing.JMenuItem();
        jMenuReservaLab = new javax.swing.JMenuItem();
        jMenuOpcao = new javax.swing.JMenu();
        jMenuDisponibilidade = new javax.swing.JMenu();
        jMenuDispoSala = new javax.swing.JMenuItem();
        jMenuDispoLab = new javax.swing.JMenuItem();

        jLabel1.setText("jLabel1");

        setTitle("Menu Usuario");
        setPreferredSize(new java.awt.Dimension(800, 620));
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        desktop.setBackground(new java.awt.Color(238, 238, 238));

        titulo.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        titulo.setText("Menu Usuario");
        titulo.setBounds(30, 30, 170, 16);
        desktop.add(titulo, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jSeparator1.setBounds(130, 120, 0, 12);
        desktop.add(jSeparator1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        juser.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        juser.setText("Usuário");
        juser.setBounds(432, 30, 70, 16);
        desktop.add(juser, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jiduser.setText("ID User");
        jiduser.setBounds(510, 30, 170, 16);
        desktop.add(jiduser, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jSeparator2.setBounds(20, 50, 730, 20);
        desktop.add(jSeparator2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jMenuUsuario.setText("Menu Usuario");

        jMenuVerificarSolicitacao.setText("Menu Verificar Solicitacao");
        jMenuVerificarSolicitacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuVerificarSolicitacaoActionPerformed(evt);
            }
        });
        jMenuUsuario.add(jMenuVerificarSolicitacao);

        jMenuReserva.setText("Menu Reserva");

        jMenuReservaSala.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/book.png"))); // NOI18N
        jMenuReservaSala.setText("Menu Reserva Sala");
        jMenuReservaSala.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuReservaSalaActionPerformed(evt);
            }
        });
        jMenuReserva.add(jMenuReservaSala);

        jMenuReservaLab.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/server.png"))); // NOI18N
        jMenuReservaLab.setText("Menu Reserva Laboratório");
        jMenuReservaLab.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuReservaLabActionPerformed(evt);
            }
        });
        jMenuReserva.add(jMenuReservaLab);

        jMenuUsuario.add(jMenuReserva);

        jMenuBar1.add(jMenuUsuario);

        jMenuOpcao.setText("Menu Opcao");

        jMenuDisponibilidade.setText("Menu Disponibilidade");

        jMenuDispoSala.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/book.png"))); // NOI18N
        jMenuDispoSala.setText("Menu Disponibilidade Sala");
        jMenuDispoSala.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuDispoSalaActionPerformed(evt);
            }
        });
        jMenuDisponibilidade.add(jMenuDispoSala);

        jMenuDispoLab.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/server.png"))); // NOI18N
        jMenuDispoLab.setText("Menu Disponibilidade Laboratorio");
        jMenuDispoLab.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuDispoLabActionPerformed(evt);
            }
        });
        jMenuDisponibilidade.add(jMenuDispoLab);

        jMenuOpcao.add(jMenuDisponibilidade);

        jMenuBar1.add(jMenuOpcao);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(desktop, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(desktop, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 552, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuDispoSalaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuDispoSalaActionPerformed
        // TODO add your handling code here:
        desktop.removeAll();

        salaDisponivel();

        desktop.add(salaDispo);

        Main.log.info("Tela Salas Disponiveis acessada!");
    }//GEN-LAST:event_jMenuDispoSalaActionPerformed

    private void jMenuReservaSalaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuReservaSalaActionPerformed
        // TODO add your handling code here:
        desktop.removeAll();

        novaSala();

        desktop.add(salaRes);
        
    }//GEN-LAST:event_jMenuReservaSalaActionPerformed

    private void jMenuVerificarSolicitacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuVerificarSolicitacaoActionPerformed
        // TODO add your handling code here:
        desktop.removeAll();

        novoReservas();

        desktop.add(reservas);
    }//GEN-LAST:event_jMenuVerificarSolicitacaoActionPerformed

    private void jMenuDispoLabActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuDispoLabActionPerformed
        // TODO add your handling code here:

        if(idioma.equals("en_US")){
            JOptionPane.showMessageDialog(null, "Sorry, but this functionality isn't working!", "Sorry!", JOptionPane.ERROR_MESSAGE);
        }else{
            JOptionPane.showMessageDialog(null, "Desculpe, mas essa funcionalidade não está funcionando!", "Desculpa!", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jMenuDispoLabActionPerformed

    private void jMenuReservaLabActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuReservaLabActionPerformed
        // TODO add your handling code here:

        if(idioma.equals("en_US")){
            JOptionPane.showMessageDialog(null, "Sorry, but this functionality isn't working!", "Sorry!", JOptionPane.ERROR_MESSAGE);
        }else{
            JOptionPane.showMessageDialog(null, "Desculpe, mas essa funcionalidade não está funcionando!", "Desculpa!", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jMenuReservaLabActionPerformed

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        // TODO add your handling code here:
    }//GEN-LAST:event_formInternalFrameOpened

    public void novoReservas(){
        reservas = new VerificarReservas(idioma,usuario);
    }

    public void novaSala(){
        salaRes = new ReservarSala(idioma,usuario);
    }

    public void salaDisponivel(){
        salaDispo = new SalasDisponiveis(idioma,usuario);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane desktop;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuDispoLab;
    private javax.swing.JMenuItem jMenuDispoSala;
    private javax.swing.JMenu jMenuDisponibilidade;
    private javax.swing.JMenu jMenuOpcao;
    private javax.swing.JMenu jMenuReserva;
    private javax.swing.JMenuItem jMenuReservaLab;
    private javax.swing.JMenuItem jMenuReservaSala;
    private javax.swing.JMenu jMenuUsuario;
    private javax.swing.JMenuItem jMenuVerificarSolicitacao;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JLabel jiduser;
    private javax.swing.JLabel juser;
    private javax.swing.JLabel titulo;
    // End of variables declaration//GEN-END:variables

    public void alterarIdioma(String idioma){
        ResourceBundle palavras = ResourceBundle.getBundle("idiomas.Lingua_"+idioma);

        this.setTitle(palavras.getString("MenuUsuario.titulo"));
        
        titulo.setText(palavras.getString("MenuUsuario.titulo"));
        juser.setText(palavras.getString("verificar.user"));
        
        jMenuOpcao.setText(palavras.getString("MenuPrincipal.jMenuOpcao"));
        jMenuDisponibilidade.setText(palavras.getString("MenuPrincipal.jMenuDisponibilidade"));
        jMenuDispoSala.setText(palavras.getString("MenuPrincipal.jMenuDispoSala"));
        jMenuDispoLab.setText(palavras.getString("MenuPrincipal.jMenuDispoLab"));
        
        jMenuUsuario.setText(palavras.getString("MenuPrincipal.jMenuUsuario"));
        jMenuVerificarSolicitacao.setText(palavras.getString("MenuPrincipal.jMenuVerificarSolicitacao"));
        jMenuReserva.setText(palavras.getString("MenuPrincipal.jMenuReserva"));
        jMenuReservaSala.setText(palavras.getString("MenuPrincipal.jMenuReservaSala"));
        jMenuReservaLab.setText(palavras.getString("MenuPrincipal.jMenuReservaLab"));
        jMenuVerificarSolicitacao.setText(palavras.getString("MenuPrincipal.jMenuVerificarSolicitacao"));

        
    }

}
